// pages/shop/shop.js
Page({
  data: {
    length:'',
    windowWidth:'',
    cover:'../img/cover.jpg',
    ditance:'201m',
    love:false,
    note:'重庆市江北区观音桥步行街重庆市江北区观音桥步行街重庆市江北区观音桥步行街重庆市江北区观音桥步行街',
    long: 0, 
    margin: 30,
    size: 14,
    ad: ['../img/ad.jpg', '../img/ad.jpg', '../img/ad.jpg'],
    pro: [{ src: '../img/pro1.jpg', icon: '../img/tuan.jpg', name: '仅售226元！价值312元的4人自助午餐，提供免费WiFi。', now: '226.00', price: '200.00', url: '../pro/pro' }, { src: '../img/pro2.jpg', icon: '../img/pin.jpg', name: '9小时欢唱+酒水套餐', now: '226.00', price: '20.00', url: '../pro/pro' }, { src: '../img/pro3.jpg', icon: '../img/quan.jpg', name: '【2店通用】美联英语', now: '226.00', price: '20.00', url: '../pro/pro' }, { src: '../img/pro4.jpg', icon: '../img/quan.jpg', name: '重庆动物园', now: '226.00', price: '20.00', url: '../pro/pro' }, { src: '../img/pro5.jpg', icon: '../img/pin.jpg', name: '妍姿美睫美甲生活馆', now: '226.00', price: '20.00', url: '../pro/pro' }],
    shop: { logo: '../img/ll1.png', name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购物广场店）', owner: '马先生', tel: '12467809890' }


  },
  home: function (e) {
    wx.switchTab({
      url: '../index/index',
    })
  },
  onShow: function () {
    var that = this;
    var length = that.data.note.length * that.data.size;
    var windowWidth = wx.getSystemInfoSync().windowWidth;
    that.setData({
      length: length,
      windowWidth: windowWidth
    });
    that.scrolltxt();
  },
  scrolltxt: function () {
    var that = this;
    var length = that.data.length;
    var windowWidth = that.data.windowWidth;
    if (length > windowWidth) {
      var interval = setInterval(function () {
        var maxscrollwidth = length + that.data.margin;
        var crentleft = that.data.long;
        if (crentleft < maxscrollwidth) {
          that.setData({
            long: crentleft + 1
          })
        }
        else {
          that.setData({
            long: 0
          });
          clearInterval(interval);
          that.scrolltxt();
        }
      }, 20);
    }
    else {
      that.setData({ margin: "1000" });
    }
  },
  onLoad: function (options) {

  },
  onReady: function () {

  }
})